from selenium.webdriver.common.by import By

from pageobjects.BasePage import BasePage


class ListPage(BasePage):
    __CLICK_BLOG = (By.XPATH,'//a[text()="写博客"]')
    # __CLICK_HOME_PAGE = (By.XPATH,'//a[text()="主页"]')
    def click_write(self):
        self.do_click(self.__CLICK_BLOG)
        from pageobjects.EditPage import EditPage
        return EditPage(self.driver)


    def view_blog(self, title):
        text = f'//div[text()="{title}"]/following-sibling::a[@class="detail"]'
        click_view = (By.XPATH, text)
        self.do_click(click_view)
        from pageobjects.BlogPage import BlogPage
        return BlogPage(self.driver)
    # def click_home_page(self):
    #     self.do_click(self.__CLICK_HOME_PAGE)